{% extends 'front/front_base.html' %}
{% block title %}
    爱派森学院
{% endblock %}
{% block css %}
    <link rel="stylesheet" href="{{ static('front/css/front_index.css') }}">
{% endblock %}
{% block content %}
    <div class="lg-container">
        <div id="carousel-example-generic" class="carousel slide index-banner" data-ride="carousel">
            <!-- 指示器 -->
            <ol class="carousel-indicators">
                <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
                <li data-target="#carousel-example-generic" data-slide-to="1"></li>
                <li data-target="#carousel-example-generic" data-slide-to="2"></li>
                <li data-target="#carousel-example-generic" data-slide-to="3"></li>
                <li data-target="#carousel-example-generic" data-slide-to="4"></li>
            </ol>

            <!-- 轮播图 -->
            <div class="carousel-inner" role="listbox">
                {% for banner in banners %}
                    {% if loop.first %}
                        <div class="item active">
                    {% else %}
                        <div class="item ">
                    {% endif %}


                <a href="{{ banner.link_url }}"><img st src="{{ banner.image_url }}" alt=""></a>
                </div>

                {% endfor %}
                </div>

                <!-- 左右切换的控制按钮 -->
                <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
                    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                    <span class="sr-only">Previous</span>
                </a>
                <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
                    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                    <span class="sr-only">Next</span>
                </a>
            </div>

            <div class="post-group">
                <ul class="post-group-head">
                    <li class="{% if sort==1 %}active{% endif %}"><a href="{{ url_for('front.index',sort=1,bd=board_id)  }}">最新</a></li>
                    <li class="{% if sort==2 %}active{% endif %}"><a href="{{ url_for('front.index',sort=2,bd=board_id) }}">精华帖子</a></li>
                    <li class="{% if sort==3 %}active{% endif %}"><a href="{{ url_for('front.index',sort=3,bd=board_id) }}">点赞最多</a></li>
                    <li class="{% if sort==4 %}active{% endif %}"><a href="{{ url_for('front.index',sort=4,bd=board_id) }}">评论最多</a></li>
                </ul>
                <ul class="post-list-group">
                    {% for post in posts %}
                        <li>
                            <div class="author-avatar-group">
                                <img src="{{ post.author.avatar or url_for('static',filename='common/images/logo.jpg') }}"
                                     alt="">
                            </div>
                            <div class="post-info-group">
                                <a href="{{ url_for('front.post_detail',post_id=post.id) }}"><p class="post-title">
                                    {{ post.title }}
                                    {% if post.highlight %}
                                        <span class="label label-danger">
                                    精华帖子
                                    </span>
                                    {% endif %}
                                </p></a>

                                <p class="post-info">
                                    <span>作者:{{ post.author.username }}</span>
                                    <span>发表时间:{{ post.create_time|time_format }}</span>
                                    <span>评论:0</span>
                                    <span>阅读 :0</span>
                                </p>


                            </div>
                        </li>

                    {% endfor %}

                </ul>
                <div class="pagination-bottom">
                    {{ pagination.links }}
                </div>

            </div>
        </div>
        <div class="sm-container">
            <div>
                <button class="btn btn-warning btn-block" style="margin-bottom: 10px">
                    <a href="{{ url_for('front.add_post') }}">发布帖子</a>
                </button>
            </div>
            <div class="list-group">
                {% if current_board %}
                    <a href="/" class="list-group-item">
                        所有板块
                    </a>
                    {% for board in boards %}
                        {% if board.id==current_board %}
                            <a href="{{ url_for('front.index',bd=board.id) }}"
                               class="list-group-item active">{{ board.name }}</a>
                        {% else %}
                            <a href="{{ url_for('front.index',bd=board.id) }}"
                               class="list-group-item">{{ board.name }}</a>
                        {% endif %}

                    {% endfor %}
                {% else %}
                    <a href="/" class="list-group-item active">
                        所有板块
                    </a>
                    {% for board in boards %}
                        <a href="{{ url_for('front.index',bd=board.id) }}" class="list-group-item">{{ board.name }}</a>
                    {% endfor %}
                {% endif %}


            </div>
        </div>
    </div>


{% endblock %}